package org.ecloud.base.monitor.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class JvmUtil {

	private static Logger logger = LoggerFactory.getLogger(JvmUtil.class);
	
	public static void jvm() {
		// 打印JVM信息。
		if (logger.isDebugEnabled()) {
			logger.debug("最大内存: {}M", Runtime.getRuntime().maxMemory() / 1024 / 1024);
			logger.debug("已分配内存: {}M", Runtime.getRuntime().totalMemory() / 1024 / 1024);
			logger.debug("已用内存: {}M", (Runtime.getRuntime().maxMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024);
			logger.debug("可用内存: {}M", (Runtime.getRuntime().maxMemory() - Runtime.getRuntime().totalMemory() + Runtime.getRuntime().freeMemory()) / 1024 / 1024);
		}
	}

}
